package com.github.catvod.spider.merge;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.Cipher;

public class O {
  private static PublicKey BQ(String paramString) {
    X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(aF.h(paramString));
    return KeyFactory.getInstance("RSA").generatePublic(x509EncodedKeySpec);
  }
  
  public static String I(String paramString1, String paramString2) {
    try {
      PublicKey publicKey = BQ(paramString2);
      Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
      cipher.init(1, publicKey);
      return new String(aF.V0(cipher.doFinal(paramString1.getBytes("UTF-8"))));
    } catch (Exception exception) {
      PrintStream printStream = System.out;
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append("sadsad4");
      stringBuilder.append(exception);
      printStream.println(stringBuilder.toString());
      return null;
    } 
  }
  
  public static String V0(String paramString1, String paramString2) {
    PublicKey publicKey = BQ(paramString1);
    Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
    cipher.init(2, publicKey);
    return new String(cipher.doFinal(aF.h(paramString2)));
  }
  
  public static String h(String paramString1, String paramString2) {
    PrivateKey privateKey = oC(paramString2);
    Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
    cipher.init(2, privateKey);
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(aF.h(paramString1));
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    byte[] arrayOfByte = new byte[256];
    while (true) {
      int i = byteArrayInputStream.read(arrayOfByte);
      if (i != -1) {
        byte[] arrayOfByte1;
        if (256 == i) {
          arrayOfByte1 = arrayOfByte;
        } else {
          byte[] arrayOfByte2 = new byte[i];
          byte b = 0;
          while (true) {
            arrayOfByte1 = arrayOfByte2;
            if (b < i) {
              arrayOfByte2[b] = arrayOfByte[b];
              b++;
              continue;
            } 
            break;
          } 
        } 
        byteArrayOutputStream.write(cipher.doFinal(arrayOfByte1));
        continue;
      } 
      return new String(byteArrayOutputStream.toByteArray());
    } 
  }
  
  public static String j(String paramString1, String paramString2) {
    String str = "error";
    byte[] arrayOfByte = aF.h(paramString2);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    try {
      PublicKey publicKey = BQ(paramString1);
      Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
      cipher.init(2, publicKey);
      int j = arrayOfByte.length;
      int i = 0;
      byte b = 0;
      while (true) {
        byte[] arrayOfByte1;
        int k = j - i;
        if (k <= 0) {
          String str1;
          byte[] arrayOfByte2 = byteArrayOutputStream.toByteArray();
          byteArrayOutputStream.close();
          if (arrayOfByte2 == null) {
            str1 = str;
          } else {
            str1 = new String((byte[])str1);
          } 
          return str1;
        } 
        if (k > 128) {
          arrayOfByte1 = cipher.doFinal(arrayOfByte, i, 128);
        } else {
          arrayOfByte1 = cipher.doFinal(arrayOfByte, i, k);
        } 
        byteArrayOutputStream.write(arrayOfByte1, 0, arrayOfByte1.length);
        i = ++b * 128;
      } 
    } catch (Exception exception) {
      return "error";
    } 
  }
  
  public static PrivateKey oC(String paramString) {
    PKCS8EncodedKeySpec pKCS8EncodedKeySpec = new PKCS8EncodedKeySpec(aF.h(paramString));
    return KeyFactory.getInstance("RSA").generatePrivate(pKCS8EncodedKeySpec);
  }
  
  public static String q(String paramString1, String paramString2) {
    try {
      Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
      KeyFactory keyFactory = KeyFactory.getInstance("RSA");
      X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec();
      this(aF.h(paramString1));
      cipher.init(1, keyFactory.generatePublic(x509EncodedKeySpec));
      int j = (paramString2.getBytes()).length;
      ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
      this();
      int i = 0;
      byte b = 0;
      while (true) {
        byte[] arrayOfByte;
        int k = j - i;
        if (k <= 0) {
          arrayOfByte = byteArrayOutputStream.toByteArray();
          byteArrayOutputStream.close();
          return aF.V0(arrayOfByte);
        } 
        if (k > 117) {
          arrayOfByte = cipher.doFinal(paramString2.getBytes(), i, 117);
        } else {
          arrayOfByte = cipher.doFinal(paramString2.getBytes(), i, k);
        } 
        byteArrayOutputStream.write(arrayOfByte, 0, arrayOfByte.length);
        i = ++b * 117;
      } 
    } catch (Exception exception) {
      return "error";
    } 
  }
}


/* Location:              /Users/hetaiyi/Desktop/my/tech/java/study/aa/temp/temp.jar!/com/github/catvod/spider/merge/O.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */